package com.ruicar.afs.cloud.apply.pre.loan.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.apply.common.entity.ApplyCustAddressDetails;
import com.ruicar.afs.cloud.apply.pre.loan.condition.CustInfoCondition;
import com.ruicar.afs.cloud.apply.pre.loan.mapper.ApplyCustAddressMapper;
import com.ruicar.afs.cloud.apply.pre.loan.service.ApplyCustAddressService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description
 * @Author 客户地址明细service实现类
 * @Date2020/5/14 16:38
 * @Version V1.0
 **/
@Service
public class ApplyCustAddressServiceImpl extends ServiceImpl<ApplyCustAddressMapper, ApplyCustAddressDetails> implements ApplyCustAddressService {

    /**
     * 根据条件获取客户地址明细
     *
     * @param condition
     * @return
     */
    public ApplyCustAddressDetails getCustAddress(CustInfoCondition condition) {

        return this.baseMapper.getAddress(condition);
    }

    /**
     * 通过申请编号获取地址信息列表
     *
     * @param applyNo
     * @return
     */
    public List<ApplyCustAddressDetails> getCustAddressDetailsList(String applyNo) {

        List<ApplyCustAddressDetails> addressDetailsList = this.baseMapper.selectList(Wrappers.<ApplyCustAddressDetails>query().lambda()
                .eq(ApplyCustAddressDetails::getApplyNo, applyNo));
        return addressDetailsList;
    }

    /**
     * 通过申请编号和客户ID获取地址信息列表
     *
     * @param applyNo
     * @param custId
     * @return
     */
    public List<ApplyCustAddressDetails> getCustAddressDetailsList(String applyNo, Long custId) {

        List<ApplyCustAddressDetails> addressDetailsList = this.baseMapper.selectList(Wrappers.<ApplyCustAddressDetails>query().lambda()
                .eq(ApplyCustAddressDetails::getApplyNo, applyNo).eq(ApplyCustAddressDetails::getCustId, custId));
        return addressDetailsList;
    }

}
